import request from '@/utils/request'

// 获取班次列表（分页）
export function getShiftPage(params) {
  return request({
    url: '/shifts/page',
    method: 'get',
    params
  })
}

// 导入班次
export function importShifts(file) {
  const formData = new FormData()
  formData.append('file', file)
  
  console.log('FormData内容:')
  for (let [key, value] of formData.entries()) {
    console.log(key, value)
  }
  
  return request({
    url: '/shifts/import',
    method: 'post',
    data: formData,
    // 删除Content-Type，让浏览器自动设置，这样会包含正确的boundary
    transformRequest: [function (data, headers) {
      delete headers['Content-Type']
      return data
    }],
    // 设置超时时间，避免大文件上传超时
    timeout: 60000
  })
}